/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package com.aptech.validate;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

/**
 *
 * @author KG
 */
public class CustomerValidator {
    public CustomerValidator(){
    }
    public static boolean checkName(String n) {

        if (n == null || n.length() == 0) {
            return false;
        } else {
            String strPattern = "[^a-zA-Z ]";

            Pattern p;
            Matcher m;
            int flag = Pattern.CASE_INSENSITIVE;
            p = Pattern.compile(strPattern, flag);
            m = p.matcher(n);
            return !m.find();
        }
    }
    /**
     * Method  checkSpace(),to check value is space.
     * @return boolean true or false .
     * @param n 
     */
//    public static boolean checkSpace(String n) {
//        String strPattern = "[^ ]";
//        Pattern p;
//        Matcher m;
//        int flag = Pattern.CASE_INSENSITIVE;
//        p = Pattern.compile(strPattern, flag);
//        m = p.matcher(n);
//        return m.find();
//
//    }
       public static boolean checkAddress(String address) {
        Pattern pattern;
        Matcher matcher;

        final String ADDRESS_PATTERN = "^[a-zA-Z0-9_ -]{3,50}$";

        pattern = Pattern.compile(ADDRESS_PATTERN);

        matcher = pattern.matcher(address);

        return matcher.matches();
    }
    /**
     * Method to check Email
     * @return boolean true or false
     * @param n 
     */
    public static boolean checkEmail(String email) {
        Pattern pattern;
        Matcher matcher;

        final String EMAIL_PATTERN = "^[_A-Za-z0-9-\\+]+(\\.[_A-Za-z0-9-]+)*@"
		+ "[A-Za-z0-9-]+(\\.[A-Za-z0-9]+)*(\\.[A-Za-z]{2,})$";

        pattern = Pattern.compile(EMAIL_PATTERN);

        matcher = pattern.matcher(email);

        return matcher.matches();
    }
    public static boolean checkPhone(String n) {
        if (n == null || n.length() > 15 || n.length() < 7) {
            return false;
        } else {
            String strPattern = "[^0-9]";
            Pattern p;
            Matcher m;
            int flag = Pattern.CASE_INSENSITIVE;
            p = Pattern.compile(strPattern, flag);
            m = p.matcher(n);
            return !m.find();
        }
    }
       public static boolean checkNumber(String n) {
        if (n == null || n.length() > 10  || n.length() < 1) {
            return false;
        } else {
            String strPattern = "[^0-9.]";
            Pattern p;
            Matcher m;
            int flag = Pattern.CASE_INSENSITIVE;
            p = Pattern.compile(strPattern, flag);
            m = p.matcher(n);
            return !m.find();
        }
    }
       public static boolean check(String n) {
        if (n == null || n.length() == 0) {
            return false;
        }
        return true;
    }
     /**
     * Method  checkID(),to  check input ID.
     * @return boolean true or false .
     * @param n 
     */

}
